package com.hafiery.sdk.bluetooth.transport.adapter;

import android.text.TextUtils;
import com.google.gson.Gson;
import com.hafiery.sdk.bluetooth.util.LogUtil;

import java.util.ArrayList;

public class RecordFilesAdapter implements DataAdapter<Files>{
    @Override
    public Files parse(byte[] data) {
        String jsonStr=new String(data);
        if(TextUtils.isEmpty(jsonStr)){
            return new Files("",0,new ArrayList<>());
        }else{
            LogUtil.log("JSON:"+new String(data));
            try{
                Files files=new Gson().fromJson(new String(data),Files.class);
                return files;
            }catch (Exception e){
                e.printStackTrace();
            }
            return new Files("",0,new ArrayList<>());
        }
    }
}
